<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>后盾人</title>
    <style>
      body {
        padding: 200px;
      }
      ul {
        list-style: none;
        padding: 0;
        margin: 0;
        width: 200px;
      }

      li {
        border: solid 1px #ddd;
        padding: 10px;
      }
      li:nth-of-type(odd) {
        background: yellowgreen;
      }
    </style>
  </head>
  <body>
    <input type="text" name="hd" />
    <ul></ul>
  </body>
  <script>
    let obj = {
      data: new Set(),
      keyword(word) {
        this.data.add(word);
      },
      show() {
        let ul = document.querySelector("ul");
        ul.innerHTML = "";
        this.data.forEach(function(value) {
          ul.innerHTML += `<li>${value}</li>`;
        });
      }
    };
    let input = document.querySelector("[name='hd']");
    input.addEventListener("blur", function() {
      obj.keyword(this.value);
      obj.show();
    });
  </script>
</html>
